package com.future.vo;

import com.future.enums.StatusCode;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@ApiModel("ResponseResult 响应结果对象")
@Data
@AllArgsConstructor
@NoArgsConstructor
public class ResponseResultVo {

    @ApiModelProperty("响应码")
    private Integer code;

    @ApiModelProperty("响应消息")
    private String message;

    @ApiModelProperty("响应结果")
    private Object result;

    public static ResponseResultVo success(Object result) {
        ResponseResultVo rs = new ResponseResultVo();
        rs.setCode(StatusCode.OK.getCode());
        rs.setMessage("success");
        rs.setResult(result);
        return rs;
    }

    public static ResponseResultVo success() {
        ResponseResultVo rs = new ResponseResultVo();
        rs.setCode(StatusCode.OK.getCode());
        rs.setMessage("success");
        return rs;
    }

    public static ResponseResultVo failure(StatusCode statusCode, String message) {
        ResponseResultVo rs = new ResponseResultVo();
        rs.setCode(statusCode.getCode());
        rs.setMessage(message);
        return rs;
    }
}
